package com.Dec_TwentyFour;

import java.util.Arrays;

public class Solution80 {

    public int removeDuplicates(int[] nums) {
        if (nums.length<=2) return nums.length;
        int n=nums.length,index=2;
        for (int i = 2; i < n; i++) {
            if (nums[i]!=nums[index-2]){
                nums[index++]=nums[i];
            }
        }
        //System.out.println(Arrays.toString(nums));
        return index;
    }

    public static void main(String[] args) {
        Solution80 solution80=new Solution80();
        System.out.println(solution80.removeDuplicates(new int[]{1,1,1,2,2,3}));
    }
}
